//
//  AppDelegate.m
//  07-UITabbarController
//
//  Created by dllo on 16/7/22.
//  Copyright © 2016年 LST. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"
#import "OneViewController.h"
#import "TwoViewController.h"
#import "ThreeViewController.h"
@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#if 0
    {
        self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
        ViewController *vc1 = [[ViewController alloc] init];
        vc1.view.backgroundColor = [UIColor redColor];
        vc1.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"新闻" image:nil tag:1001];
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc1];
        nav.tabBarItem.badgeValue = @"1000";
        vc1.title = @"测试";
        //    nav.navigationItem.title
        //    nav.tabBarItem.title
        // nav.navigationItem.title = @"asd";
        // 改变导航标题颜色
        [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor yellowColor]}];
        // VC中self.title 与self.navigationController.title的区别
        // 1.self.title 会修改两个内容 navigationitem.title 和 tabbarItem.title
        // 2.self.navgationItem.title 只修改navigationBar上的标题
        
        // uitabbar 标签试图控制
        // 主要管理视图层级的视图控制器
        // 1.ViewControllers所有被管里的视图控制器都在这个数组中
        //  可以通过setter的方法的形式去赋值
        // 也可以通过下述的方法进行视图控制器的赋值
        // 2.setViewControllers:animation
        // 3.通过一数组创建完成后, 如果数组中的控制器没有设置tabbarItem, 则显示一个空的tabbarItem
        // 4.tabbarItem根据自己需求去创建对应的tabBarItem
        // UIViewController的属性 (category)
        // 因为每个视图控制器的tabbarItem都不一样, 因此不能设为tabBarcontroller的属性
        // 创建方式
        // 1> initWithTabBarSystem:tag 根据系统样式创建
        // 2> initWithTitle: image: tag: 根据自定义的图片与文字创建
        // 3> initWithTitle: image:selectedImaeg: tag: 根据自定义的图片与文字创建, 增添选中图片
        // 5.如果数组个数过多(多于五时), 系统会把多余出来的内容, 统一使用一种方式去管理
        // 建议数组个数不要大于五
        // 6.tabBar (高度49)
        //  1> barTintColor bar的背景色
        //  2> tintColor 元素的颜色
        //  3> translucent bar是否透明
        //  4> badgeValue 角标
        // 7.UIAppearance 全局设置
        //    [[UITabBar appearance]setTintColor:[UIColor yellowColor]];
        //    [[UITabBar appearance] setBackgroundColor:[UIColor cyanColor]];
        //    [[UINavigationBar appearance]setBarTintColor:[UIColor whiteColor]];
        UITabBarController *tabbar = [[UITabBarController alloc] init];
        //    _window.backgroundColor = [UIColor whiteColor];
        self.window.rootViewController = tabbar;
        // tabbar.tabBar.barTintColor = [UIColor purpleColor];
        // tabbar.tabBar.tintColor = [UIColor blackColor];
        //tabbar.tabBar.backgroundImage = [UIImage imageNamed:@""];
        // tabbar.tabBar.translucent = NO;
        ViewController *vc = [[ViewController alloc] init];
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:vc];
        [tabbar setViewControllers:@[navController]];
        // 设置tabBarItem时, 给你要放进数组中的控制器去设置
        navController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"新闻" image:nil tag:0];
        // 设置标题
        vc.navigationItem.title = @"NEWS";
        [self.window makeKeyAndVisible];
    }
#endif
#if 1
    {
        self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
        _window.backgroundColor = [UIColor whiteColor];
        UITabBarController *tabbar = [[UITabBarController alloc] init];
       // ViewController *root = [[ViewController alloc] init];
        OneViewController *one = [[OneViewController alloc] init];
        TwoViewController *two = [[TwoViewController alloc] init];
        ThreeViewController *three = [[ThreeViewController alloc] init];
        UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:one];
        UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:two];
        UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:three];
        one.title = @"one";
        two.title = @"two";
        three.title = @"three";
        
        
        tabbar.viewControllers = @[nav1, nav2, nav3];
        self.window.rootViewController = tabbar;
        [self.window makeKeyAndVisible];
    }
#endif
    return YES;
    // rootViewControll tabBar
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
